package Spark2JDBC

import org.apache.spark.sql.{DataFrame, SparkSession}

/**
  * Created by Administrator on 2018/5/28.
  */
object JsonDataSource {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession
      .builder()
      .appName("JsonDataSource")
      .master("local[*]")
      .getOrCreate()

    import spark.implicits._
    val jsons: DataFrame = spark.read.json("D:\\SparkTestData\\json")

    val filtered: DataFrame = jsons.where($"age" <= 500)

    filtered.printSchema()
    filtered.show()

    spark.stop()
  }
}
